﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ChineseSchool.Models.Hethong;
using System.Data;

namespace ChineseSchool.BLL
{
    public class B_UserType
    {
        private PetaPoco.Database db;
        public B_UserType()
        {
            db = new PetaPoco.Database("ConnectionString");
        }

        public List<M_UserType> GetAlls()
        {
            var UserType = db.Fetch<M_UserType>(@";EXEC UserType_Get_List");
            return UserType;
        }

        // Select by ID
        public M_UserType Selectby_id(int UserTypeID)
        {
            var loadmenu = db.SingleOrDefault<M_UserType>("SELECT * FROM tiengtrungminha.UserType bc WHERE bc.UserTypeID = " + UserTypeID + ";");
            db.CloseSharedConnection();
            return loadmenu;
        }

        public M_UserType Selectby_Type(string type)
        {
            var loadmenu = db.SingleOrDefault<M_UserType>("SELECT * FROM tiengtrungminha.UserType bc WHERE bc.Type = '" + type + "';");
            db.CloseSharedConnection();
            return loadmenu;
        }
    }
}